package com.mewpipe.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mewpipe.dao.DaoFactory;
import com.mewpipe.dao.UserDao;
import com.mewpipe.dao.VideoDao;
import com.mewpipe.entity.Video;

/**
 * Servlet implementation class search
 */
@WebServlet("/search")
public class search extends HttpServlet {
	
	private VideoDao videoDao;
	@Override
	public void init() throws ServletException {
		videoDao = DaoFactory.getInstance().getVideoDao();
	}
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String nom = request.getParameter("searchfield");
		String idshare = videoDao.getVideoSearch(nom);
		//req.getRequestDispatcher("/Index").forward(req, resp);
		
		
				response.sendRedirect(request.getServletContext().getContextPath()+"/play?id="+idshare);
	}

}
